package com.itheima.d11_api_objects;

import java.util.Objects;

/*
    Objects是一个工具类，提供了很多操作对象的静态方法给我们使用。
        public static boolean equals(Object a, Object b)	先做非空判断，再比较两个对象
        public static boolean isNull(Object obj) 	判断对象是否为null，为null返回true ,反之
        public static boolean nonNull(Object obj) 	判断对象是否不为null，不为null则返回true, 反之
 */
public class Test {
    public static void main(String[] args) throws Exception{
        Student s1 = new Student("张三", 19, "男");
        Student s2 = new Student("李四", 29, "男");
        s1 = null;
        try {
            s1.equals(s2);
        } catch (Exception e) {
            System.out.println(false);
        }
    }

    @org.junit.Test
    public void test1(){
        Student s1 = new Student("张三", 19, "男");
        Student s2 = new Student("李四", 29, "男");
        s1 = null;
        System.out.println(Objects.isNull(s1));
        System.out.println(Objects.equals(s1, s2));
    }

    @org.junit.Test
    public void test2(){
        int i = 330;
        Integer i2 = 330;
        int i3 = 330;
        String s2 = "abc";
        String s3 = "abc";
        System.out.println(s2 == s3);
        System.out.println(System.identityHashCode(s2) == System.identityHashCode(s3));
        System.out.println(System.identityHashCode(i) + ":" + System.identityHashCode(i2) + ":" + System.identityHashCode(i3));
        System.out.println(i2.toString() + 1);
        System.out.println(Integer.toString(i2) +2);
        String s1 = "30";
        System.out.println(Integer.valueOf(s1) + 1);
        System.out.println(Integer.parseInt(s1) + 2);
    }
}
